home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Expert 1995 Winter
/
Mac Expert - Winter 95.iso
/
Les fichiers
/
P.I.M.s
/
PCalc 1.0 ƒ
/
PCalc Functions
< prev
next >
Wrap
Text File
|
1992-12-02
|
5KB
|
331 lines
••• PCalc 1.0 External Functions by James Thomson
This document contains the definitions of the functions that appear under the
'Functions' menu in PCalc.
Each function starts with the line 'def <functionName>' followed by any number
of the commands below, each on a separate line, and is terminated by a line
with a single 'end' on it. Note that if the name has a '/' followed by character
at the end, this will be used as the command-key in the menu.
Also, the keyword 'separatorLine' adds a grey separator line to the menu and
'hierMenu <hierMenuName>' creates a submenu in which the functions that follow
appear. A 'hierEnd' or another 'heirMenu <name>' finishes each submenu.
The maximum number of functions is 512 at the moment in 32 submenus, any extra
will be ignored. Do you really need any more than that?
If a function only makes sense in a certain mode, it is a good idea to prefix
the rest of the definition with a 'dec', 'hex' or 'bin' so the calculator will
automatically switch mode. For example 'set x 42' when in hex mode sets
the display to the hex value $42, not to forty-two. If any errors occur (such
as an overflow) when applying a function, the calculator will beep.
Look at the function definitions below for examples to make things clearer.
Please mail me any functions you write that you think would be useful to others
and I will include them with the next version, credited to you.
••• Known Commands
x is the name of any register
y is the name of any register or an actual value
set x y : x = y
clr x : x = 0
add x y : x = x + y
sub x y : x = x - y
mul x y : x = x * y
div x y : x = x / y
pwr x y : x = x to the power of y
neg x : x = -x
inv x : x = 1/x
trn x : x = truncate x to integer
rnd x : x = round x to nearest integer
fac x : x = factorial of x
exp x : x = e to the power of x
log x : x = log base 10 of x
ln x : x = natural log of x
sin x : x = sine x
cos x : x = cosine x
tan x : x = tangant x
asn x : x = inverse sine x
acs x : x = inverse cosine x
atn x : x = inverse tanget x
+ value : shortcut add that works on main register
- value : shortcut subtract that works on main register
* value : shortcut multiply that works on main register
/ value : shortcut divide that works on main register
= x y : sets x to 1 if x = y, to 0 otherwise
> x y : sets x to 1 if x > y, to 0 otherwise
< x y : sets x to 1 if x < y, to 0 otherwise
=> x y : sets x to 1 if x => y, to 0 otherwise
<= x y : sets x to 1 if x <= y, to 0 otherwise
dec : change mode to decimal
hex : change mode to hexadecimal
bin : change mode to binary
deg : change angle measurement to degrees
rad : change angle measurement to radians
In binary and hex modes only :
and x y : x = bitwise and of x and y
or x y : x = bitwise or of x and y
xor x y : x = bitwise xor of x and y
not x y : x = bitwise not of x
••• Known Registers
x : main register
m : memory
y : second memory
r1, r2, ...rF : sixteen registers for storing intermediate results
••• Known Constants
PI : value of π
••• Function Definitions
hierMenu Conversion
def Inches to Millimetres
dec
mul x 25.4
end
def Millimetres to Inches
dec
div x 25.4
end
def Miles to Kilometres
dec
mul x 1.61
end
def Kilometres to Miles
dec
div x 1.61
end
def Gallons to Litres
dec
mul x 3.78541
end
def Litres to Gallons
dec
div x 3.78541
end
def Pounds to Kilograms
dec
mul x 0.45359237
end
def Kilograms to Pounds
dec
div x 0.45359237
end
def Ounces to Grams
dec
mul x 28.3495
end
def Grams to Ounces
dec
div x 28.3495
end
def °F to °C
dec
sub x 32
mul x 5
div x 9
end
def °C to °F
dec
mul x 9
div x 5
add x 32
end
def Degrees to Radians
dec
div x 57.29577951308232
end
def Radians to Degrees
dec
mul x 57.29577951308232
end
def Megabytes to Bytes
dec
mul x 1048576
end
def Bytes to Megabytes
dec
div x 1048576
end
hierMenu Trigonometric
def Hyperbolic Sine
dec
set r1 x
set r2 x
neg r2
exp r1
exp r2
sub r1 r2
div r1 2
set x r1
end
def Hyperbolic Cosine
dec
set r1 x
set r2 x
neg r2
exp r1
exp r2
add r1 r2
div r1 2
set x r1
end
def Hyperbolic Tangent
dec
set r1 x
set r2 x
set r3 x
set r4 x
neg r2
neg r4
exp r1
exp r2
exp r3
exp r4
sub r1 r2
add r3 r4
div r1 r3
set x r1
end
def Inverse Hyp Sine
dec
set r1 x
pwr x 2
add x 1
pwr x 0.5
add x r1
ln x
end
def Inverse Hyp Cosine
dec
set r1 x
pwr x 2
sub x 1
pwr x 0.5
add x r1
ln x
end
def Inverse Hyp Tangent
dec
set r1 x
set r2 x
set r3 1
sub r3 r2
add r1 1
div r1 r3
ln r1
div r1 2
set x r1
end
def Secant
dec
cos x
inv x
end
def Cosecant
dec
sin x
inv x
end
def Cotangent
dec
tan x
inv x
end
hierMenu Financial
def Add VAT at 17.5%
dec
mul x 1.175
end
def Round to Nearest
dec
mul x 100
add x 0.5
rnd x
div x 100
end
hierMenu Memory
def Clear Memory
set m 0
end
def Add Memory
add x m
end
def Subtract Memory
sub x m
end
def Multiply by Memory
mul x m
end
def Divide by Memory
div x m
end
def Raise to Memory
pwr x m
end
••• End Of Functions
By the way, you can remove all the comments in this file to free up some memory
if you need it. Click at the right end of the black strip that says 'PCalc' on
the calculator to display the ammount of free memory available and the memory
used up by the functions. Enjoy!